package com.changgou.service.goods.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.changgou.goods.pojo.Brand;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

//public interface BrandMapper extends Mapper<Brand> {
@Mapper
public interface BrandMapper extends BaseMapper<Brand> {
    /**
     * 根据分类名称查询品牌列表
     *
     * @param categoryName
     * @return
     */
//    @Select("select * from tb_brand as brand where brand.id in (select brand_id from tb_category_brand where category in (select id from tb_category where name = #{category}))")
    @Select("select brand.* from tb_brand as brand " +
            "inner join tb_category_brand on brand.id = tb_category_brand.brand_id " +
            "inner join tb_category on tb_category_brand.category_id = tb_category.id " +
            "where tb_category.name = #{categoryName}")
    List<Brand> findListByCategoryName(@Param("category") String categoryName);
}